//
//  SEGTabBar.m
//  SEGUhomeStandard
//
//  Created by 刘山 on 2018/4/11.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGTabBar.h"

@implementation SEGTabBar
- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        // 去掉TabBar顶部线的颜色
        [self setShadowImage:[UIImage imageWithColor:kColor_W]];
        [self setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]]];
        
        [self addSubview:self.tabBarView];
    }
    return self;
}

-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
    [super traitCollectionDidChange:previousTraitCollection];
    [self setShadowImage:[UIImage imageWithColor:kColor_W]];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.tabBarView.frame = CGRectMake(0, -kTabBarItemOverHeight, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds)+kTabBarItemOverHeight);
    [self bringSubviewToFront:self.tabBarView];
    [self.tabBarView segLayoutSubviews];
}

- (SEGTabBarView *)tabBarView
{
    if (!_tabBarView) {
        _tabBarView = [[SEGTabBarView alloc]initWithFrame:CGRectZero];
    }
    return _tabBarView;
}

@end
